package com.naiterui.ehp.bs.doctor.controller.inner;

import com.naiterui.ehp.bp.constants.SwaggerTag;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bp.support.exception.PublicService;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bs.doctor.exception.ExceptionCodes;
import com.naiterui.ehp.bs.doctor.service.IDoctorService;

/**
 * @author guoyongxiang
 * @date 2019/12/2 19:54
 * @since 1.0.0
 */
@RequestMapping("ad/inner/esign")
@RestController
@Api(tags = {SwaggerTag.DOCTOR + SwaggerTag.INNER_API + SwaggerTag.CA_ESIGN})
public class AdInnerEsignController {

    private static final Logger LOGGER = LoggerFactory.getLogger(AdInnerEsignController.class);

    @Autowired
    private IDoctorService doctorService;

    @RequestMapping("auth/result")
    public ResponseVO<Void> userAuth(Long userId, Integer status, String reason) {
        LOGGER.info("医生电子签名账户审核回调 userId:{}, status:{}, reason:{}", userId, status, reason);
        return PublicService.returnResponseVO(ExceptionCodes.SUCCESS);
    }

    /**
     * CA用户回写CA生成的签章图片
     * @param sealImage
     * @param doctorId
     * @return
     */
    @PostMapping("perfect/sealimage")
    public ResponseVO<Void> perfectSealImage(String sealImage, Long doctorId) throws BusinessException {
        LOGGER.info("回写三方机构生成签章图片， doctorId {}, sealImage {}", doctorId, sealImage);
        doctorService.perfectSealImage(sealImage, doctorId);
        return PublicService.returnResponseVO(ExceptionCodes.SUCCESS);
    }
}
